package chapter7.TreeMap;

import java.util.*;
public class Example {
    public static void main(String[] args) {
        Person person1 = new Person("马先生", 181);
        Person person2 = new Person("李先生", 193);
        Person person3 = new Person("王小姐", 186);
        Map<Number, Person> map = new HashMap<Number, Person>();
        map.put(person1.getId_card(), person1);
        map.put(person2.getId_card(), person2);
        map.put(person3.getId_card(), person3);
        TreeMap<Number, Person> treeMap = new TreeMap<Number, Person>();
        treeMap.putAll(map);
        Iterator<Number> it = treeMap.keySet().iterator();
        while (it.hasNext()){
            Person person = treeMap.get(it.next());
            System.out.println(person.getId_card() + " " + person.getName());
        }
    }
}